package com.shop.loan.model;

import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.upms.helper.HyperModelCreatorVo;

import javax.persistence.*;
import java.math.BigDecimal;

@Setter
@Getter
@Erupt(
        name = "支付宝支付订单",
        power = @Power(add = false, edit = false, delete = false, viewDetails = false)

)
@Table(name = "s_alipay_order")
@Entity
@ApiModel("支付宝支付订单")
public class AliPayOrder extends HyperModelCreatorVo {

    @Column(name = "order_id")
    private Long orderId;

    @EruptField(
            views = @View(title = "用户", column = "name"),
            edit = @Edit(
                    title = "用户",
                    search = @Search(vague = true),
                    type = EditType.REFERENCE_TREE
            )
    )
    @JoinColumn(name = "rental_user_id")
    @ManyToOne
    private User rentalUser;

    @EruptField(
            views = @View(title = "名称"),
            edit = @Edit(title = "名称")
    )
    private String name;

    @EruptField(
            views = @View(title = "商户订单号"),
            edit = @Edit(title = "商户订单号", search = @Search)
    )
    private String outTradeNo;

    @EruptField(
            views = @View(title = "订单金额"),
            edit = @Edit(title = "订单金额")
    )
    private BigDecimal totalAmount;

    @EruptField(
            views = @View(title = "实收金额"),
            edit = @Edit(title = "实收金额")
    )
    private BigDecimal receiptAmount;

    @EruptField(
            views = @View(title = "支付状态"),
            edit = @Edit(
                    title = "支付状态",
                    type = EditType.CHOICE,
                    search = @Search(),
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "等待付款", value = "WAIT_BUYER_PAY"),
                                    @VL(label = "支付关闭", value = "TRADE_CLOSED"),
                                    @VL(label = "支付成功", value = "TRADE_SUCCESS"),
                                    @VL(label = "交易结束", value = "TRADE_FINISHED"),
                            }
                    ))
    )
    private String status;


    @EruptField(
            views = @View(title = "支付类型"),
            edit = @Edit(
                    title = "支付类型",
                    type = EditType.CHOICE,
                    search = @Search(),
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "首款", value = "P"),
                                    @VL(label = "屏幕险", value = "S"),
                                    @VL(label = "货款", value = "R"),
                                    @VL(label = "买断", value = "B"),
                                    @VL(label = "首款+屏幕险", value = "PS"),
                            }
                    ))
    )
    private String payType;

    @EruptField(
            views = @View(title = "订单类型"),
            edit = @Edit(
                    title = "订单类型",
                    type = EditType.CHOICE,
                    search = @Search(),
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "预授权", value = "1"),
                                    @VL(label = "支付", value = "2"),
                                    @VL(label = "代扣", value = "3"),
                            }
                    ))
    )
    private Integer type;


    @EruptField(
            views = @View(title = "支付宝交易号"),
            edit = @Edit(title = "支付宝交易号")
    )
    private String tradeNo;

    @EruptField(
            views = @View(title = "商户业务号"),
            edit = @Edit(title = "商户业务号")
    )
    private String outBizNo;

    @EruptField(
            views = @View(title = "预授权订单号"),
            edit = @Edit(title = "预授权订单号")
    )
    private String authNo;

    @EruptField(
            views = @View(title = "下单平台"),
            edit = @Edit(
                    title = "下单平台",
                    type = EditType.CHOICE,
                    search = @Search(),
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "支付宝", value = "alipay"),
                                    @VL(label = "微信", value = "wx"),
                                    @VL(label = "h5", value = "h5"),
                                    @VL(label = "app", value = "app"),
                            }
                    ))
    )
    private String pFrom;



    @EruptField(
            views = @View(title = "支付平台"),
            edit = @Edit(
                    title = "支付平台",
                    type = EditType.CHOICE,
                    search = @Search(),
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "支付宝", value = "alipay"),
                                    @VL(label = "微信", value = "wx"),
                                    @VL(label = "合利宝", value = "hlb"),
                                    @VL(label = "拉卡拉", value = "lkl"),
                            }
                    ))
    )
    private String payFrom;

    //  是否线上支付
    @Transient
    private Boolean isOnLine;

    //备注
    @Transient
    private String remark;

    //还款类型
    @Transient
    private Integer payment;

}
